/*
    www.cguage.com
    1.2 求数组1比数组2大的个数总和
*/

#include <iostream>
#include <sstream>
#include <cassert>
#include <vector>
using namespace std;

#ifndef TEST
#define IN(iss) {                       \
        std::string str;                \
        std::getline(std::cin, str);    \
        iss.str(str);                   \
    }
#define OUT(s) std::cout << s
#endif

#define READ_N(iss, n) {    \
    iss >> n;               \
    iss.ignore(1, ',');     \
}

int main() {
    istringstream iss;
    IN(iss);
    assert(!iss.eof());

    // 解析到两个数组(空格分隔)
    string tmp;
    istringstream issArr[2];
    vector<int> v[2];
    int n = 0;
    for (int i = 0; i < 2; ++i) {
        iss >> tmp;
        issArr[i].str(tmp);
        while (!issArr[i].eof()) {
            READ_N(issArr[i], n);
            v[i].push_back(n);
        }
    }

    // 思路: 只要v1[i]比v2[j]大, 则大于v2[j]的就有v1.size - i个
    int total = 0;
    int i = 0;
    int j = 0;
    while (i < v[0].size() && j < v[1].size()) {
        if (v[0][i] <= v[1][j]) {
            ++i;
        } else {
            ++j;
            total += v[0].size() - i;
        }
    }


    // 结果
    ostringstream oss;
    oss << total;
    OUT(oss.str());
    return 0;
}

#ifdef TEST
struct TestCase CASES[] = {
    /*0*/{"1,3,5,7,9 2,3,4,7,8", "12"},
    /*1*/{"1,2,3,4,5 999", "0"},
    /*2*/{"2,7,9 0", "3"}
};
#endif